package com.thx.information.dao;

import com.thx.common.orm.PaginationDao;
import com.thx.information.model.InformationExt;

import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

@Repository
public class InformationExtDao extends PaginationDao<InformationExt> {

  private static final Logger logger = LoggerFactory.getLogger(InformationExtDao.class);

  /**
   * 查询某公文的浏览次数.
   * 
   * @param infoId
   * @return
   */
  public Long queryViewCountByInfoId(Long infoId) {
    String hql = "select count(*) from InformationExt where infoId= ? " ;
    Object obj = createQuery(hql, new Object[] {infoId}).uniqueResult();
    return obj != null ? NumberUtils.toLong(obj.toString()) : 0L;
  }


}
